<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_GtkEntry extends TemplateGtkGladeWidgetCompilerBase{

	protected function compileCreateWidget_( TemplateGtkGladeWidget $oObject ){
		$sWidgetClass=$oObject->getWidgetClass();
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);
		$sCompiled="\t\t{$sVariableName}=new {$sWidgetClass}();";
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('editable'))===false){// 可编辑
			$sCompiled.="\t\t{$sVariableName}->set_editable(false);";
		}
		if(($sMaxLen=$oObject->getProperty('max_length'))){// 最大长度
			$sCompiled.="\t\t{$sVariableName}->set_max_length({$sMaxLen});";
		}
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('visibility'))===false){// 可见状态
			$sCompiled.="\t\t{$sVariableName}->set_visibility(false);";
		}
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('has_frame'))===false){// 有无边框
			$sCompiled.="\t\t{$sVariableName}->set_has_frame(true);";
		}
		if(($sInvisibleChar=$oObject->getProperty('invisible_char'))){// 不可见字符
			$sCompiled.="\t\t{$sVariableName}->set_property('invisible-char','{$sInvisibleChar}');";
		}
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('activates_default'))){// 默认激活
			$sCompiled.="\t\t{$sVariableName}->set_activates_default(true);";
		}
		if(($sWidthChars=$oObject->getProperty('width_chars'))){// 字符宽
			$sCompiled.="\t\t{$sVariableName}->set_width_chars({$sWidthChars});";
		}
		if(($sText=$oObject->getProperty('text'))!==null){// 预设文本
			$sCompiled.="\t\t{$sVariableName}->set_text(\"{$sText}\");";
		}
		if(($sXAlign=$oObject->getProperty('xalign'))){// 水平对齐
			$sCompiled.="\t\t{$sVariableName}->set_alignment(\"{$sXAlign}\");";
		}
		// 截断多行
		//if(TemplateGtkGladeObj::nodeTextToValue($sMaxLen=$oObject->getProperty('truncate_multiline')))
		// $sCompiled.="\t\t{$sVariableName}->set_property('xalign',\"{$sXAlign}\");";

		// 阴影类型
		//if($sShadowType=$oObj->getProperty('shadow_type'))
		// $sCompiled.="\t\t{$sVariableName}->set_shadow_type('xalign',\"{$sXAlign}\");";
		return $sCompiled;
	}

	protected function compileChildWidgetPacking_(TemplateGtkGladeWidget $oParentWidget,TemplateGtkGladeWidget $oChildWidget,TemplateGtkGladeWidgetPacking $oPacking){
		$sParentVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oParentWidget);// 父/子 窗体变量名
		$sChildWidgetVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oChildWidget);
		$sChildWidgetName=$oChildWidget->getWidgetId();// 子窗体名
		$sCompiled="\t\t{$sChildWidgetVariableName}=\$this->getWidget('{$sChildWidgetName}',\$arrObjectForSignal);";
		return $sCompiled;
	}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor(str_replace('TemplateGtkGladeWidgetCompiler_','',__CLASS__),__CLASS__);
	}

}
